<link rel="stylesheet" href="<?php echo URL::base() ?>media/vendor/css/style.css" type="text/css" media="all"/>
<script src="<?php echo URL::base() ?>media/js/jquery-1.10.1.min.js"></script>

<link rel="stylesheet" href="<?php echo URL::base() ?>media/vendor/artdialog/skins/default.css" type="text/css"
      media="all"/>
<script src="<?php echo URL::base() ?>media/vendor/artdialog/jquery.artDialog.js"></script>

<link href="<?php echo URL::base() ?>media/vendor/css/ui-lightness/jquery-ui-1.10.4.custom.css" rel="stylesheet">
<script src="<?php echo URL::base() ?>media/vendor/js/jquery-1.10.2.js"></script>
<script src="<?php echo URL::base() ?>media/vendor/js/jquery-ui-1.10.4.custom.js"></script>
<script src="<?php echo URL::base() ?>media/vendor/js/jquery.ui.datepicker-zh-TW.js"></script>
<style type="text/css">
    .display_div {
        display: none
    }

    .table tbody tr th {
        font-weight: normal;
    }
</style>
<script type="text/javascript">

    var globe_dialog = {};
    /**
     * 显示详细的信息
     */
    function show_purchase_one_sku(view) {
        art.dialog({
            title: '采购单详情',
            lock: true,
            opacity: 0.87,	// 透明度
            content: view,
            button: [
                {
                    name: '关闭',
                    callback: function () {
                        window.location.reload();

                    }}
            ]
        });
    }
    /**
     * 点击下单弹出
     */
    function purchase_on_click_fun(sku) {
        if (sku
            && (sku.replace(/(^\s*)|(\s*$)/g, ""))) {
            var url = "<?php echo url::base(true)?>warning/purchaseonesku";
            url += "?sku=" + sku;

            /**
             *
             */
            /*window.open(url);*/

            /**
             * @20141001新的方法，不需要跳转页面
             */
            var dialog = art.dialog({
                title:"系统下单",
                content:'数据获取中...',
                lock:true,
                opacity:0.87,
                fixed:true,
                drag:false,
                resize:false
            });
            $.get(url,function(data){
                dialog.position('0%','0%');
                dialog.size('100%','100%');
                dialog.content(data);
                globe_dialog = {};
                globe_dialog = dialog;
            });
        }
    }

    /**
     * 点击不下单触发时间
     */
    function nopurchase_on_click_fun(sku) {
        /**
         * 使用array =》 sku
         * 状态 status
         * @type {{}}
         */
        if (sku
            && (sku.replace(/(^\s*)|(\s*$)/g, ""))) {
            var data = [];
            var sku = {"sku": sku, "status": 1};
            data.push(sku);
            $.ajax({
                type: 'post',
                url: '<?php echo url::base(true)?>warning/nowarning_one',
                dataType: 'json',
                data: {"data": data, 'status': 1},
                async: false,
                success: function (data) {
                    if (data) {
                        alert('操作成功');
                        window.location.reload();
                    }
                    else {
                        alert('操作失败');
                    }
                },
                error: function () {
                    alert('error');
                }
            });
        }
    }

    function btn_click_flush(obj)
    {
        var url = "<?php echo url::base(true)?>warning/flushwarninghandle";
        var dialog = art.dialog({
            title:"更新数据",
            content:'数据更新中...',
            lock:true,
            opacity:0.87,
            fixed:true,
            drag:false,
            resize:false
        });
        $.get(url,function(data){
            dialog.content(data);
        })
    }
</script>
<div>
    <div>
        <input type="hidden" id="daystype" value="<?php if(isset($showback['days'])){
            echo $showback['days'];
        } ?>"/>

        <form action="<?php echo url::base(true) ?>warning/index" method="get" id="sel_form">
            <a class="btn" id="daystype_1" href="<?php echo url::base(true) ?>warning/index?days=1">今日下单</a>
            <a class="btn" id="daystype_3" href="<?php echo url::base(true) ?>warning/index?days=3">三日下单</a>
            <a class="btn" id="daystype_7" href="<?php echo url::base(true) ?>warning/index?days=7">七日下单</a>
<span>sku
<input type="text" placeholder="" name="sku" class="input-medium" value="<?php if(isset($showback['sku'])){
    echo $showback['sku'];
} ?>"></span>
            <button type="submit" class="btn btn-info" id="sel_submit">查询</button>
        </form>
    </div>
    <div>
        最后更新时间<?php if(isset($lasttime)){
            echo $lasttime;
        }else{
            echo "0000-00-00";
        } ?>
        <!--<a class="btn btn-info" href="<?php /*echo url::base(true) */?>warning/flushwarninghandle" target="_blank">手动刷新</a>-->
        <button class="btn btn-info" id="flush_btn" onclick="btn_click_flush(this)">手动刷新</button>
    </div>
    <script type="text/javascript">
        var daystype = $("#daystype").val();
        $("#daystype_" + daystype).addClass("btn-info");
    </script>
    <?php if(true){ ?>
        <span>当前采购人员<?php echo user::active_user()->name ?></span>
        <span id='skunumber'>本页总共有<?php echo count($skulists); ?>条SKU下单信息</span>
        <input type="hidden" value="<?php echo count($skulists); ?>" id="skusum">
        <a href="<?php echo url::base(true) ?>warning/warning_sku_lists" target="_blank"
           class="btn btn-info">不下单的SKU</a>
    <?php } ?>
</div>

<div style=" margin-top:20px;">
    <?php if(isset($skulists) and !empty($skulists)){ ?>
        <div id="table_<?php echo $sku['sku'] ?>">
            <table class="table table-bordered" style="table-layout:fixed;">
                <tbody>

                <tr style=" background-color:#4EA392;color:#fff;">
                    <th>
                        序号
                    </th>
                    <th style="width:70px;">
                        SKU
                    </th>
                    <th>

                        下单提示
                    </th>
                    <th>
                        实际可用库存
                    </th>
                    <th>
                        在途库存
                    </th>
                    <th>
                        日均销量
                    </th>
                    <th>
                        可支持天数
                    </th>
                    <th>
                        误差天数
                    </th>
                    <th>
                        最佳下单日期
                    </th>
                    <th>
                        默认目标时间段
                    </th>
                    <th>
                        建议采购量
                    </th>
                    <th>
                        预交期
                    </th>
                    <th>
                        操作
                    </th>
                    <th>
                        采购支持详情
                    </th>
                </tr>
                <?php foreach($skulists as $num => $sku){
                    ?>
                    <tr>

                        <td>
                            <?php echo $num+1 ?>
                        </td>

                        <td>
                            <!--SKU-->
                            <a href="<?php echo url::base(true).'advancewarning/index?sku='.$sku['sku'] ?>"
                               target="_blank"><?php echo $sku['sku'] ?></a>
                        </td>

                        <td>
                            <!--下单提示-->
                            <?php echo isset($sku['tips'])?$sku['tips']:''?>
                        </td>

                        <td>
                            <!--实际可用库存-->
                            <?php echo isset($sku['inventory']['actual_available_num'])?$sku['inventory']['actual_available_num']:'' ?>
                        </td>

                        <td>
                            <!--在途库存-->
                            <?php echo isset($sku['inventory']['pp_num'])?$sku['inventory']['pp_num']:'' ?>
                        </td>

                        <td>
                            <!--日均销量-->
                            <?php echo isset($sku['daysales'])?$sku['daysales']:'' ?>
                        </td>

                        <td>
                            <!--可支持天数-->
                            <?php echo isset($sku['supp_days'])?$sku['supp_days']:''?>
                        </td>
                        <td>
                            <!--误差天数-->
                            <?php echo isset($sku['misdays'])?$sku['misdays']:''?>
                        </td>

                        <td>
                            <!--最佳下单日期-->
                            <?php echo isset($sku['best'])?$sku['best']:''?>
                        </td>

                        <td>
                            <!-- 默认目标时间段 -->
                            <?php echo isset($sku['target_time'])?$sku['target_time']:'' ?>/天
                        </td>
                        <td>
                            <!-- 建议采购量 -->
                            <?php echo isset($sku['suggest'])?$sku['suggest']:''?>
                        </td>

                        <td>
                            <!-- 预交期  -->
                            <?php echo isset($sku['delivery'])?$sku['delivery']:'' ?>
                        </td>
                        <td>
                            <input type="button" value="采购" class="btn btn-info addpurchase"
                                   onclick=purchase_on_click_fun("<?php echo $sku['sku']; ?>")
                                   id="addpurchase_<?php echo $sku['sku'] ?>">
                            <input type="button" value="不采购" class="btn btn-info nowarning"
                                   onclick=nopurchase_on_click_fun("<?php echo $sku['sku']; ?>")
                                   id="nowarning_<?php echo $sku['sku'] ?>">
                        </td>
                        <td>
                            <a href="<?php echo url::base(true).'advancewarning/index?sku='.$sku['sku'] ?>"
                               target="_blank"><?php echo '采购支持详情查看' ?></a>
                        </td>
                    </tr>
                <?php } ?>
            </table>
        </div>
    <?php } ?>
    <input type="hidden" name="current_uri" id="current_url" value="<?php echo url::base(true) ?>">
    <?php if(isset($pagination)){
        echo $pagination;
    } ?>
</div>
									
							

  
